﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Process.Api.Application.Command;
using Process.DAL;
using Process.ErrorCod;
using Process.Model;

namespace Process.Api.Controllers
{
    /// <summary>
    /// 工艺流程服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessFlowController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProcessFlowController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> CreateProcessFlow(CreateProcessFlowCommand request)
        {
            return await mediator.Send(request);

        }
        /// <summary>
        /// 获取工艺流程列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiPageing<ProcessFlow>> GetProcessFlow([FromQuery]GetProcessFlowListCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> DeleteProcessFlow(DeleteProcessFlowCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 查看工艺流程详情
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<ProcessFlow>> DetailProcessFlow([FromQuery]DetailProcessFlowCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 更新工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateProcessFlow(UpdateProcessFlowCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
